package com.beauty.product.document;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDate;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "products")
public class ProductDocument {

    @Id
    private String id;

    @Field(type = FieldType.Text)
    private String name;

    @Field(type = FieldType.Keyword)
    private String sku;

    @Field(type = FieldType.Keyword)
    private String price;

    @Field(type = FieldType.Keyword)
    private String originalPrice;

    @Field(type = FieldType.Long)
    private Long categoryId;

    @Field(type = FieldType.Text)
    private String brand;

    @Field(type = FieldType.Text)
    private String description;

    @Field(type = FieldType.Text)
    private String coverImage;

    @Field(type = FieldType.Boolean)
    private Boolean isPublished;

    @Field(type = FieldType.Boolean)
    private Boolean isRecommended;

    @Field(type = FieldType.Boolean)
    private Boolean isNew;

    @Field(type = FieldType.Boolean)
    private Boolean isHot;

    @Field(type = FieldType.Integer)
    private Integer sort;

    @Field(type = FieldType.Integer)
    private Integer sales;

    @Field(type = FieldType.Date, format = {}, pattern = "yyyy-MM-dd")
    private LocalDate createdTime;

    @Field(type = FieldType.Date, format = {}, pattern = "yyyy-MM-dd")
    private LocalDate updatedTime;

    @Field(type = FieldType.Nested)
    private List<ProductAttributeDocument> attributes;

    @Field(type = FieldType.Keyword)
    private List<String> imageUrls;
}
